pub fn convert_base(num_str: &str, to_base: u32) -> String {
    // 将输入字符串按括号分割，提取数字和源进制
    let parts: Vec<&str> = num_str.split('(').collect();
    let value = parts[0].trim();
    let from_base: u32 = parts[1].trim().replace(")", "").parse().expect("Invalid source base");

    // 将输入值从源进制转换为十进制
    let decimal_value = u32::from_str_radix(value, from_base).expect("Invalid number in the given base");

    // 检查目标进制是否合法
    if to_base < 2 || to_base > 16 {
        return "Error: Target base must be between 2 and 16".to_string();
    }

    // 将十进制值转换为目标进制
    if decimal_value == 0 {
        return "0".to_string(); // 特殊情况，处理0
    }

    let mut result = String::new();
    let mut num = decimal_value;

    while num > 0 {
        let remainder = num % to_base;
        let digit = if remainder < 10 {
            (b'0' + remainder as u8) as char
        } else {
            (b'a' + (remainder - 10) as u8) as char
        };
        result.push(digit);
        num /= to_base;
    }

    // 反转字符串，因为我们是从低位到高位构造结果
    result.chars().rev().collect()//aa
}